package com.yukh.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.support.SessionStatus;

import com.yukh.dao.UserInfo;
import com.yukh.service.UserManagerService;

@Controller("/userManager.action")
public class UserManagerController extends BaseController{
	@Autowired
	UserManagerService userManagerService;
	
	@RequestMapping(params = "method=toLogin")
	public String toLogin(){
		return "login/user_login";
	}
	
	/*EventMapping 
	 * public String render(ModelMap modelMap, SessionStatus status,
            RenderRequest request, RenderResponse response) {
		return "";
	}*/
	
	@RequestMapping(params = "method=toUserLogin")
	public String toUserLogin(ModelMap mm){
		List<UserInfo> userInfoList = userManagerService.selectUserInfoAll("selectUserInfoAll");
		mm.addAttribute("userInfoList", userInfoList);
		return "login/user_list";
	}
	
	@RequestMapping(params = "method=saveUserLogin")
	public String saveUserLogin(UserInfo userInfo){
		userManagerService.saveUserInfo(userInfo);
		return "redirect:/userManager.action?method=toUserLogin";
	}
	
	@RequestMapping(params = "method=userAdd")
	public void userAdd(UserInfo userInfo){
		userInfo.setUserName("name");
		userInfo.setUserAge("1");
//		userManagerService.save("insertUserInfo", userInfo);
		
		System.out.println("1");
	}
}
